﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SyOrderStateEntity
{
    public abstract class SyOrderState : IChangeSyOrderStatus
    {
        public ISyOrder SyOrder { get; set; }
        public SyStateContext SyStateContext { get; set; }
        public IList<SyOrderStatusModel> GetChangeOrderStatus(SyOrderOperatorUserType syOrderOperatorUserType)
        {
            return SyOrderOperatorFactory.CreateSyOrderOperator(syOrderOperatorUserType).GetChangeOrderStatus(this);
        }
        public bool ChangeSyOrderStatus(SyOrderOperatorUserType syOrderOperatorUserType, SyOrderStatus updateSyOrderStatus)
        {
            IList<SyOrderStatusModel> statusList = this.GetChangeOrderStatus(syOrderOperatorUserType);
            if (null != statusList && statusList.Count > 0)
            {
                var statusModel = (from model in statusList.Skip(1) where model.SyOrderStatus == updateSyOrderStatus select model).FirstOrDefault();
                if (null != statusModel)
                {
                    //更改状态
                    return true;
                }
            }
            return false;
        }
        public abstract bool LockSyOrder(SyOrderOperatorUserType syOrderOperatorUserType);

        internal abstract IList<SyOrderStatusModel> GetSyOrderOperatorAdministorOrderStatus();

        internal abstract IList<SyOrderStatusModel> GetSyOrderOperatorCustomServiceOrderStatus();

        internal abstract IList<SyOrderStatusModel> GetSyOrderOperatorGoodServiceOrderStatus();
    }
}
